package com.lj.queue.param;

import cn.hutool.core.collection.CollUtil;
import com.lj.mp.utils.AbstractPageQueryParams;
import io.swagger.v3.oas.annotations.media.Schema;
import jakarta.validation.constraints.NotNull;
import lombok.Data;
import lombok.EqualsAndHashCode;

import java.time.LocalDateTime;
import java.util.List;

/**
 * <p>
 * 延迟队列消息表 分页查询参数
 * </p>
 *
 * @author lj
 * @since 2025-07-21 16:55:02
 */
@Data
@EqualsAndHashCode(callSuper = true)
@Schema(description = "延迟队列消息表 分页查询参数")
public class DelayQueueMessagePageParam extends AbstractPageQueryParams {

    @Schema(description = "延迟队列id")
    @NotNull(message = "队列id不能为空!")
    private Long queueId;

    @Schema(description = "消息状态 参考字典: DelayQueueMessageStatus")
    private Integer status;

    @Schema(description = "预计时间,如果长度为2,那么第一个是开始，第二个是结束")
    private List<LocalDateTime> expectTime;

    @Schema(description = "预计时间-开始")
    private LocalDateTime expectTimeStart;

    @Schema(description = "预计时间-结束")
    private LocalDateTime expectTimeEnd;

    public void setExpectTime(List<LocalDateTime> expectTime) {
        if (CollUtil.isNotEmpty(expectTime) && expectTime.size() >= 2) {
            this.setExpectTimeStart(expectTime.get(0));
            this.setExpectTimeEnd(expectTime.get(1));
        }
        this.expectTime = expectTime;
    }
}
